package com.huaxin.hxcloud.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.huaxin.common.BaseActivity;
import com.huaxin.common.Constants;
import com.huaxin.common.Entity.WorkTask;
import com.huaxin.common.utils.SpacesItemDecoration;
import com.huaxin.hxcloud.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * @author lwjing
 * @date 2018/3/19
 * @Desc $desc$
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxStationSignInActivity extends BaseActivity {

    @BindView(R.id.toolbar)
    Toolbar      mToolbar;
    @BindView(R.id.tv_station_name)
    TextView     tv_station_name;
    @BindView(R.id.iv_station_img)
    ImageView    iv_station_img;
    @BindView(R.id.tv_signin_time)
    TextView     tv_signin_time;
    @BindView(R.id.tv_station_signin_address)
    TextView     tv_signin_address;
    @BindView(R.id.tv_refresh_address)
    TextView     tv_refresh_address;
    @BindView(R.id.rl_worktask_waitdo)
    RecyclerView rl_worktask;

    WorkTaskAdapter workTaskAdapter;
    List<WorkTask> workTasks = new ArrayList<>();
    private View emptyView;
    private String stationCode;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_station_sign_in;
    }

    @Override
    protected int getLoadFrameId() {
        return R.id.content;
    }

    public static void start(Context context, String stationCode) {
        Intent intent = new Intent(context, HxStationSignInActivity.class);
        intent.putExtra(Constants.IK_STATION_CODE, stationCode);
        context.startActivity(intent);
    }

    @Override
    protected void getBundleExtras(Bundle extras) {
        super.getBundleExtras(extras);
        if (extras.containsKey(Constants.IK_STATION_CODE)) {
            stationCode = extras.getString(Constants.IK_STATION_CODE);
        } else {
            finish();
        }
    }

    @Override
    public void initView() {
        mToolbar.setTitle("厂站签到");
        setSupportActionBar(mToolbar);
        workTasks.add(new WorkTask());
        workTasks.add(new WorkTask());
        workTasks.add(new WorkTask());
        rl_worktask.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL,
                false));
        workTaskAdapter = new WorkTaskAdapter(R.layout.item_worktask_waitdo, workTasks);
        rl_worktask.setAdapter(workTaskAdapter);
        //设置条目间距
        rl_worktask.addItemDecoration(new SpacesItemDecoration(80));

        //空布局
        emptyView = LayoutInflater.from(this).inflate(R.layout.item_empty_nodata_center, (ViewGroup) rl_worktask.getParent(), false);


    }

    @Override
    protected void requestData() {
        super.requestData();

    }

    class WorkTaskAdapter extends BaseQuickAdapter<WorkTask, BaseViewHolder> {

        public WorkTaskAdapter(int layoutResId, @Nullable List<WorkTask> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder baseViewHolder, WorkTask workTask) {
            TextView tv_name = baseViewHolder.getView(R.id.tv_worktask_name);
            TextView tv_goto = baseViewHolder.getView(R.id.tv_goto);
            TextView tv_who_report = baseViewHolder.getView(R.id.tv_who_report);
            TextView tv_report_phone = baseViewHolder.getView(R.id.tv_report_phone);
            TextView tv_task_address = baseViewHolder.getView(R.id.tv_task_address);
            TextView tv_report_time = baseViewHolder.getView(R.id.tv_report_time);

        }
    }
}
